export default defineNuxtPlugin(() => {
    // 预加载所有图标
    const icons = import.meta.glob('~/assets/icons/*.svg', {
        eager: true,
        import: 'default',
        query: '?raw'
    })

    const iconMap: Record<string, string> = {}

    for (const path in icons) {
        const iconName = path.split('/').pop()?.replace('.svg', '')
        if (iconName) {
            iconMap[iconName] = icons[path] as string
        }
    }
    return {
        provide: {
            icons: {
                get: (name: string) => iconMap[name] || null,
                list: () => Object.keys(iconMap)
            }
        }
    }
})
